package com.woniu40.petai_user.mapper;

import com.woniu40.petai_user.entity.Article;
import com.woniu40.petai_user.entity.Collect;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
@Repository
public interface CollectMapper {
    int deleteByPrimaryKey(Integer collectId);
    //添加个人收藏文章
    @Insert("INSERT INTO t_collect VALUES( NULL , #{userId} , #{articleId} , #{dateTime})")
    int insertNewCollectInfo(@Param("userId") Integer userId , @Param("articleId") Integer articleId , @Param("dateTime") Date dateTime);

    Collect selectByPrimaryKey(Integer collectId);

    List<Collect> selectAll();

    int updateByPrimaryKey(Collect record);

    @Select("SELECT a.* FROM t_article a , t_collect c WHERE c.article_id = a.article_id AND c.user_id = #{value}")
    List<Article> selectCollectArticle(Integer userId);

    int deleteCol(Integer collectId);

    Collect selectCol(@Param("articleId") Integer articleId, @Param("userId") Integer userId);
}